<template>
   <div>
        <ve-table
            fixed-header
            :max-height="maxHeight"
            :columns="columns"
            :table-data="tableData"
            :scroll-width="600"
            border-y
            border-x 
        />
        <noData v-show="tableData.length == 0" showData style="height:160px"></noData>
   </div>
</template>
<script>
import noData from '@/components/base/noData.vue'
export default {
    name:'calibrationTable',
    components:{noData},
    props:{
        maxHeight:{
            type:String,
            default:'200px'
        },
        titleList:{
            type:Array,
            default:()=>{
                return []
            }
        },
        tableData:{
            type:Array,
            default:()=>{
                return []
            } 
        },
        showRoleEdit:{
            type:Number,
            default:0
        },
        showRoleDel:{
            type:Number,
            default:0
        }
    },
    data() {
        return{
            
        }
    },
    computed:{
        columns(){
            let columns = [{
                field: "index",
                key: "index",
                operationColumn: true,
                title: "序号",
                width: 50,
                fixed: "left",
                renderBodyCell: ({ row, column, rowIndex }, h) => {
                    return ++rowIndex;
                },
                },{
                    field: "pointName",
                    key: "pointName",
                    title: "测点名称",
                    edit:false,
                    width: 150,
                }
            ]

            if(this.titleList.length > 0){
                this.titleList.forEach(item=>{
                    columns.push({
                        title: item.paramName,
                        field:item.param,
                        key:item.param,
                        edit:false,
                        width: 220,
                    })
                })
            }
            columns.push({
                title: '日期',
                field:'dt',
                key:'dt',
                edit:false,
                width: 180,
            },{
                title: '操作',
                field:'opraty',
                key:'opraty',
                edit:false,
                width:160,
                renderBodyCell: ({ row, column, rowIndex }, h) => {
                    return (
                        <div>
                            <el-tooltip class="item" effect="dark" content="无编辑权限" placement="top-start" disabled={this.showRoleEdit == 1}>
                                <el-link class="typesBtn" type="primary" icon="el-icon-edit" underline={false}
                            on-click={() => this.handleAddPointList(row)}
                            disabled={this.showRoleEdit == 0}
                            >编辑</el-link>
                            </el-tooltip>

                            <el-tooltip class="item" effect="dark" content="无删除权限" placement="top-start" disabled={this.showRoleDel == 1}>
                               <el-link class="typesBtn" type="danger"  icon="el-icon-delete" underline={false}style="margin-left:10px"
                            on-click={() => this.handleDelPointList(row)}
                             disabled={this.showRoleDel == 0}
                            >删除</el-link>
                            </el-tooltip>
                        </div>
                    );
                },
            }) 
        return columns
        }
    },
    methods:{
        handleAddPointList(data){
            this.$emit('edit',data)
        },
        handleDelPointList(data){
            this.$emit('del',data)
        },
    }
}
</script>
<style scoped>

</style>